package cn.csxw.openchina.ui.adapter.adapter_myMessage;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

import butterknife.BindView;
import cn.csxw.openchina.R;
import cn.csxw.openchina.base.BaseRecAdapter;
import cn.csxw.openchina.entity.bean.ActiveBean;
import cn.csxw.openchina.utils.Global;

/**
 * 我-->消息---》@我
 */

public class MyMessageAdapter extends BaseRecAdapter<ActiveBean> {
    public MyMessageAdapter(ArrayList<ActiveBean> data) {
        super(data);
    }
    @Override
    protected void onItemClick(View v, int position) {

    }

    @Override
    protected BaseViewHolder getViewHolder(View itemView) {
        return new MyMessageHolder(itemView);
    }

    @Override
    protected View getItemView(ViewGroup parent) {
        return Global.inflate(R.layout.view_fragment_message, parent);
    }

    class MyMessageHolder extends BaseViewHolder {

        public MyMessageHolder(View itemView) {
            super(itemView);
        }
        @BindView(R.id.iv_follow_photo)
        ImageView mIvFollowPhoto;
        @BindView(R.id.tv_follow_name)
        TextView mTvFollowName;
        @BindView(R.id.tv_follow_address)
        TextView mTvFollowAddress;
        @BindView(R.id.tv_follow_des)
        TextView mTvFollowDes;
        @BindView(R.id.tv_message_time)
        TextView mTvMessageTime;

        @Override
        public void setData(ActiveBean activeBean, int Position) {
            mTvFollowName.setText(activeBean.author);
            mTvFollowAddress.setText(activeBean.catalog);

            mTvFollowDes.setText(activeBean.message);
            mTvMessageTime.setText(activeBean.pubDate);
            //http://192.168.1.107:8080/oschina/images/uploads/user/1209/2418638_50.jpg?t=1437278343000
            String portrait = activeBean.portrait;
            portrait.replace("http://192.168.1.107:8080/oschina/","http://10.0.2.2:8080/oschina/");
            Glide.with(Global.mContext).load(portrait).into(mIvFollowPhoto);
        }
    }
}
